package org.lex.swing.busyicon;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public class DefaultBusyIconResource implements IBusyIconResource {
	private static final DefaultBusyIconResource INSTANCE = new DefaultBusyIconResource();

	public static DefaultBusyIconResource getInstance() {
		return INSTANCE;
	}

	@Override
	public int getAnimationRate() {
		return this.animationRate;
	}

	@Override
	public Icon getIdleIcon() {
		return idleIcon;
	}

	@Override
	public Icon[] getBusyIcons() {
		return busyIcons;
	}

	private int animationRate = 30;
	private final Icon idleIcon;
	private final Icon[] busyIcons;

	private DefaultBusyIconResource() {
		Class<?> clz = DefaultBusyIconResource.class;
		String dir = "/org/lex/swing/busyicon/resources/";

		idleIcon = new ImageIcon(clz.getResource(dir + "idle-icon.png"));
		busyIcons = new Icon[15];
		for (int i = 0; i < busyIcons.length; i++) {
			busyIcons[i] = new ImageIcon(clz.getResource(dir + "busy-icon" + i + ".png"));
		}
	}
}
